﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace lcs.Web.inspectionMaterial
{
    public partial class Modify : Web.Admin.BasePage
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
                {
                    int inspection_id = (Convert.ToInt32(Request.Params["id"]));
                    ShowInfo(inspection_id);
                }
            }
        }

        private void ShowInfo(int inspection_id)
        {
            lcs.BLL.inspectionMaterial bll = new lcs.BLL.inspectionMaterial();
            lcs.Model.inspectionMaterial model = bll.GetModel(inspection_id);            
            this.txtdealStatus.Text = model.dealStatus.ToString();
            this.txtdealResult.Text = model.dealResult;            
            this.txtuseMoney.Text = model.useMoney.ToString();

        }

        public void btnSave_Click(object sender, EventArgs e)
        {
            if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
            {
                int inspection_id = (Convert.ToInt32(Request.Params["id"]));
                
            string strErr = "";
           
            if (!PageValidate.IsNumber(txtdealStatus.Text))
            {
                strErr += "处理状态格式错误！\\n";
            }
            if (this.txtdealResult.Text.Trim().Length == 0)
            {
                strErr += "处理结果不能为空！\\n";
            }            
            if (!PageValidate.IsDecimal(txtuseMoney.Text))
            {
                strErr += "处理费用格式错误！\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }

                int dealStatus = 0;
                int.TryParse(this.txtdealStatus.SelectedValue.ToString(),out dealStatus);
            string dealResult = this.txtdealResult.Text;
            
            decimal useMoney = decimal.Parse(this.txtuseMoney.Text);

            lcs.Model.inspectionMaterial model = new lcs.Model.inspectionMaterial(); 
            model.dealStatus = dealStatus;
            model.dealResult = dealResult;           
            model.useMoney = useMoney;
                model.inspection_id = inspection_id;
                model.dealUid = getid();
            lcs.BLL.inspectionMaterial bll = new lcs.BLL.inspectionMaterial();
            bll.UpdateJG(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "listmy.aspx");
            }

        }


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("listmy.aspx");
        }
    }
}
